package com.ztgf.shopping.api.client.epg;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgShopBannerBO;
import com.ztgf.shopping.models.dto.epg.EpgShopBannerDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import com.ztgf.shopping.models.service.epg.IEpgAggregationBannerService;
import com.ztgf.shopping.models.bo.epg.EpgAggregationBannerBO;
import com.ztgf.shopping.models.dto.epg.EpgAggregationBannerDTO;

import java.util.List;

/**
 * 聚合页banner控制器
 *
 * @author YUE
 * @Date 2020-06-04 15:36:46
 */

@RestController
@RequestMapping("/api/epgAggregationBanner")
@Slf4j
@Api(value = "EpgAggregationBannerApiController",tags = "聚合页bannerApi接口")
public class EpgAggregationBannerApiController {

    @DubboReference
    private IEpgAggregationBannerService epgAggregationBannerService;

    /**
     * 频道栏目列表 根据功能id
     * @param moduleId 功能id
     * @return
     */
    @ApiOperation(value = "频道栏目列表 根据功能id",notes = "频道栏目列表 根据功能id")
    @PostMapping("/getListByModuleId")
    public Result<List<EpgAggregationBannerDTO>> getListByModuleId(Long moduleId){
        EpgAggregationBannerBO epgAggregationBannerBO = new EpgAggregationBannerBO();
        epgAggregationBannerBO.setModuleId(moduleId);
        List<EpgAggregationBannerDTO> epgAggregationBannerDTOList = epgAggregationBannerService.getBySelectBannerInfoNoPage(epgAggregationBannerBO);
        return new Result<>(epgAggregationBannerDTOList);
    }

    @PostMapping("/get")
    @ApiOperation(value = "根据id查找",notes = "根据id查找")
    @ApiImplicitParam(name = "id",value = "id",required = true,paramType = "query", dataType = "Long")
    public Result<EpgAggregationBannerDTO> get(@RequestParam("id") Long id){
        if(id == null){
            return new Result<>(CodeEnum.FAIL_100002 );
        }

        EpgAggregationBannerDTO dto = epgAggregationBannerService.selectById(id);

        return new Result<>(dto);
    }

    @ApiOperation(value = "聚合页banner列表",notes = "聚合页banner列表")
    @PostMapping("/querySelectList")
    public Result<List<EpgAggregationBannerDTO>> querySelectList(EpgAggregationBannerBO bo){
        List<EpgAggregationBannerDTO> epgAggregationBannerDTOList = epgAggregationBannerService.getBySelectBannerInfoNoPage(bo);
        return new Result<>(epgAggregationBannerDTOList);
    }


}
